.class final Lcom/ninesky/browser/provider/downloads/o;
.super Ljava/lang/Thread;


# instance fields
.field private synthetic a:Lcom/ninesky/browser/provider/downloads/DownloadService;


# direct methods
.method public constructor <init>(Lcom/ninesky/browser/provider/downloads/DownloadService;)V
    .locals 1

    iput-object p1, p0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    const-string v0, "Download Service"

    invoke-direct {p0, v0}, Ljava/lang/Thread;-><init>(Ljava/lang/String;)V

    return-void
.end method


# virtual methods
.method public final run()V
    .locals 18

    const/16 v2, 0xa

    invoke-static {v2}, Landroid/os/Process;->setThreadPriority(I)V

    const/4 v2, 0x0

    const-wide v3, 0x7fffffffffffffffL

    :goto_0
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v5, v0

    monitor-enter v5

    :try_start_0
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v6, v0

    iget-object v6, v6, Lcom/ninesky/browser/provider/downloads/DownloadService;->a:Lcom/ninesky/browser/provider/downloads/o;

    move-object v0, v6

    move-object/from16 v1, p0

    if-eq v0, v1, :cond_0

    new-instance v2, Ljava/lang/IllegalStateException;

    const-string v3, "multiple UpdateThreads in DownloadService"

    invoke-direct {v2, v3}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v2

    :catchall_0
    move-exception v2

    monitor-exit v5
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v2

    :cond_0
    :try_start_1
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v6, v0

    invoke-static {v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->c(Lcom/ninesky/browser/provider/downloads/DownloadService;)Z

    move-result v6

    if-nez v6, :cond_5

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v6, v0

    const/4 v7, 0x0

    iput-object v7, v6, Lcom/ninesky/browser/provider/downloads/DownloadService;->a:Lcom/ninesky/browser/provider/downloads/o;

    if-nez v2, :cond_1

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-virtual {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->stopSelf()V

    :cond_1
    const-wide v6, 0x7fffffffffffffffL

    cmp-long v2, v3, v6

    if-eqz v2, :cond_2

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    const-string v6, "alarm"

    invoke-virtual {v2, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/app/AlarmManager;

    if-nez v2, :cond_4

    const-string v2, "DownloadManager"

    const-string v3, "couldn\'t get alarm manager"

    invoke-static {v2, v3}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    :cond_2
    :goto_1
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->d(Lcom/ninesky/browser/provider/downloads/DownloadService;)V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->e(Lcom/ninesky/browser/provider/downloads/DownloadService;)V

    monitor-exit v5

    :cond_3
    return-void

    :cond_4
    new-instance v6, Landroid/content/Intent;

    const-string v7, "android.intent.action.DOWNLOAD_WAKEUP"

    invoke-direct {v6, v7}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v7, v0

    invoke-virtual {v7}, Lcom/ninesky/browser/provider/downloads/DownloadService;->getApplicationContext()Landroid/content/Context;

    move-result-object v7

    invoke-virtual {v7}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v7

    const-class v8, Lcom/ninesky/browser/provider/downloads/DownloadReceiver;

    invoke-virtual {v8}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v6, v7, v8}, Landroid/content/Intent;->setClassName(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const/4 v7, 0x0

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v8, v0

    iget-object v8, v8, Lcom/ninesky/browser/provider/downloads/DownloadService;->b:Lcom/ninesky/browser/provider/downloads/l;

    invoke-interface {v8}, Lcom/ninesky/browser/provider/downloads/l;->a()J

    move-result-wide v8

    add-long/2addr v3, v8

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v8, v0

    const/4 v9, 0x0

    const/high16 v10, 0x4000

    invoke-static {v8, v9, v6, v10}, Landroid/app/PendingIntent;->getBroadcast(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v6

    invoke-virtual {v2, v7, v3, v4, v6}, Landroid/app/AlarmManager;->set(IJLandroid/app/PendingIntent;)V

    goto :goto_1

    :cond_5
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->f(Lcom/ninesky/browser/provider/downloads/DownloadService;)V

    monitor-exit v5
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    iget-object v2, v2, Lcom/ninesky/browser/provider/downloads/DownloadService;->b:Lcom/ninesky/browser/provider/downloads/l;

    invoke-interface {v2}, Lcom/ninesky/browser/provider/downloads/l;->a()J

    move-result-wide v8

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-virtual {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    sget-object v3, Lcom/ninesky/browser/provider/downloads/w;->a:Landroid/net/Uri;

    const/4 v4, 0x0

    const/4 v5, 0x0

    const/4 v6, 0x0

    const-string v7, "_id"

    invoke-virtual/range {v2 .. v7}, Landroid/content/ContentResolver;->query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v3

    if-eqz v3, :cond_3

    invoke-interface {v3}, Landroid/database/Cursor;->moveToFirst()Z

    const/4 v2, 0x0

    const/4 v4, 0x0

    const/4 v5, 0x0

    const-wide v6, 0x7fffffffffffffffL

    invoke-interface {v3}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v10

    const-string v11, "_id"

    invoke-interface {v3, v11}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v11

    move-wide v12, v6

    move v6, v2

    move v7, v5

    move v5, v4

    move v4, v10

    :goto_2
    if-eqz v4, :cond_7

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->g(Lcom/ninesky/browser/provider/downloads/DownloadService;)Ljava/util/ArrayList;

    move-result-object v2

    invoke-virtual {v2}, Ljava/util/ArrayList;->size()I

    move-result v2

    if-lt v6, v2, :cond_7

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->i(Lcom/ninesky/browser/provider/downloads/DownloadService;)Lcom/ninesky/browser/provider/downloads/i;

    move-result-object v2

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v4, v0

    invoke-static {v4}, Lcom/ninesky/browser/provider/downloads/DownloadService;->g(Lcom/ninesky/browser/provider/downloads/DownloadService;)Ljava/util/ArrayList;

    move-result-object v4

    invoke-virtual {v2, v4}, Lcom/ninesky/browser/provider/downloads/i;->a(Ljava/util/List;)V

    if-eqz v5, :cond_17

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->j(Lcom/ninesky/browser/provider/downloads/DownloadService;)Z

    move-result v2

    if-nez v2, :cond_6

    new-instance v2, Landroid/content/Intent;

    invoke-direct {v2}, Landroid/content/Intent;-><init>()V

    const-string v4, "com.android.providers.media"

    const-string v5, "com.android.providers.media.MediaScannerService"

    invoke-virtual {v2, v4, v5}, Landroid/content/Intent;->setClassName(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v4, v0

    const/4 v5, 0x1

    invoke-static {v4, v5}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Z)V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v4, v0

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v5, v0

    invoke-static {v5}, Lcom/ninesky/browser/provider/downloads/DownloadService;->k(Lcom/ninesky/browser/provider/downloads/DownloadService;)Lcom/ninesky/browser/provider/downloads/a;

    move-result-object v5

    const/4 v6, 0x1

    invoke-virtual {v4, v2, v5, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->bindService(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z

    :cond_6
    :goto_3
    invoke-interface {v3}, Landroid/database/Cursor;->close()V

    move-wide v3, v12

    move v2, v7

    goto/16 :goto_0

    :cond_7
    if-eqz v4, :cond_9

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;I)Z

    move-result v2

    if-eqz v2, :cond_8

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->h(Lcom/ninesky/browser/provider/downloads/DownloadService;)Z

    move-result v2

    if-eqz v2, :cond_8

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    const/4 v10, 0x0

    invoke-static {v2, v10, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/database/Cursor;I)Z

    :cond_8
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->b(Lcom/ninesky/browser/provider/downloads/DownloadService;I)V

    goto/16 :goto_2

    :cond_9
    invoke-interface {v3, v11}, Landroid/database/Cursor;->getInt(I)I

    move-result v10

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->g(Lcom/ninesky/browser/provider/downloads/DownloadService;)Ljava/util/ArrayList;

    move-result-object v2

    invoke-virtual {v2}, Ljava/util/ArrayList;->size()I

    move-result v2

    if-ne v6, v2, :cond_d

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v3, v6, v8, v9}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/database/Cursor;IJ)V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;I)Z

    move-result v2

    if-eqz v2, :cond_1e

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->h(Lcom/ninesky/browser/provider/downloads/DownloadService;)Z

    move-result v2

    if-eqz v2, :cond_a

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v3, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/database/Cursor;I)Z

    move-result v2

    if-nez v2, :cond_1e

    :cond_a
    const/4 v2, 0x1

    const/4 v4, 0x1

    :goto_4
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v5, v0

    invoke-static {v5, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->c(Lcom/ninesky/browser/provider/downloads/DownloadService;I)Z

    move-result v5

    if-eqz v5, :cond_b

    const/4 v4, 0x1

    :cond_b
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v5, v0

    invoke-static {v5, v6, v8, v9}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;IJ)J

    move-result-wide v14

    const-wide/16 v16, 0x0

    cmp-long v5, v14, v16

    if-nez v5, :cond_c

    const/4 v4, 0x1

    move v7, v4

    move-wide v4, v12

    :goto_5
    add-int/lit8 v6, v6, 0x1

    invoke-interface {v3}, Landroid/database/Cursor;->moveToNext()Z

    invoke-interface {v3}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v10

    move-wide v12, v4

    move v5, v2

    move v4, v10

    goto/16 :goto_2

    :cond_c
    const-wide/16 v16, 0x0

    cmp-long v5, v14, v16

    if-lez v5, :cond_1d

    cmp-long v5, v14, v12

    if-gez v5, :cond_1d

    move v7, v4

    move-wide v4, v14

    goto :goto_5

    :cond_d
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->g(Lcom/ninesky/browser/provider/downloads/DownloadService;)Ljava/util/ArrayList;

    move-result-object v2

    invoke-virtual {v2, v6}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/ninesky/browser/provider/downloads/s;

    iget v2, v2, Lcom/ninesky/browser/provider/downloads/s;->a:I

    if-ge v2, v10, :cond_f

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;I)Z

    move-result v2

    if-eqz v2, :cond_e

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->h(Lcom/ninesky/browser/provider/downloads/DownloadService;)Z

    move-result v2

    if-eqz v2, :cond_e

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    const/4 v10, 0x0

    invoke-static {v2, v10, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/database/Cursor;I)Z

    :cond_e
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->b(Lcom/ninesky/browser/provider/downloads/DownloadService;I)V

    goto/16 :goto_2

    :cond_f
    if-ne v2, v10, :cond_13

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v3, v6, v8, v9}, Lcom/ninesky/browser/provider/downloads/DownloadService;->b(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/database/Cursor;IJ)V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;I)Z

    move-result v2

    if-eqz v2, :cond_1c

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->h(Lcom/ninesky/browser/provider/downloads/DownloadService;)Z

    move-result v2

    if-eqz v2, :cond_10

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v3, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/database/Cursor;I)Z

    move-result v2

    if-nez v2, :cond_1c

    :cond_10
    const/4 v2, 0x1

    const/4 v4, 0x1

    :goto_6
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v5, v0

    invoke-static {v5, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->c(Lcom/ninesky/browser/provider/downloads/DownloadService;I)Z

    move-result v5

    if-eqz v5, :cond_11

    const/4 v4, 0x1

    :cond_11
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v5, v0

    invoke-static {v5, v6, v8, v9}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;IJ)J

    move-result-wide v14

    const-wide/16 v16, 0x0

    cmp-long v5, v14, v16

    if-nez v5, :cond_12

    const/4 v4, 0x1

    move v7, v4

    move-wide v4, v12

    :goto_7
    add-int/lit8 v6, v6, 0x1

    invoke-interface {v3}, Landroid/database/Cursor;->moveToNext()Z

    invoke-interface {v3}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v10

    move-wide v12, v4

    move v5, v2

    move v4, v10

    goto/16 :goto_2

    :cond_12
    const-wide/16 v16, 0x0

    cmp-long v5, v14, v16

    if-lez v5, :cond_1b

    cmp-long v5, v14, v12

    if-gez v5, :cond_1b

    move v7, v4

    move-wide v4, v14

    goto :goto_7

    :cond_13
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v3, v6, v8, v9}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/database/Cursor;IJ)V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;I)Z

    move-result v2

    if-eqz v2, :cond_1a

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->h(Lcom/ninesky/browser/provider/downloads/DownloadService;)Z

    move-result v2

    if-eqz v2, :cond_14

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2, v3, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/database/Cursor;I)Z

    move-result v2

    if-nez v2, :cond_1a

    :cond_14
    const/4 v2, 0x1

    const/4 v4, 0x1

    :goto_8
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v5, v0

    invoke-static {v5, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->c(Lcom/ninesky/browser/provider/downloads/DownloadService;I)Z

    move-result v5

    if-eqz v5, :cond_15

    const/4 v4, 0x1

    :cond_15
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v5, v0

    invoke-static {v5, v6, v8, v9}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;IJ)J

    move-result-wide v14

    const-wide/16 v16, 0x0

    cmp-long v5, v14, v16

    if-nez v5, :cond_16

    const/4 v4, 0x1

    move v7, v4

    move-wide v4, v12

    :goto_9
    add-int/lit8 v6, v6, 0x1

    invoke-interface {v3}, Landroid/database/Cursor;->moveToNext()Z

    invoke-interface {v3}, Landroid/database/Cursor;->isAfterLast()Z

    move-result v10

    move-wide v12, v4

    move v5, v2

    move v4, v10

    goto/16 :goto_2

    :cond_16
    const-wide/16 v16, 0x0

    cmp-long v5, v14, v16

    if-lez v5, :cond_19

    cmp-long v5, v14, v12

    if-gez v5, :cond_19

    move v7, v4

    move-wide v4, v14

    goto :goto_9

    :cond_17
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/ninesky/browser/provider/downloads/o;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    move-object v2, v0

    invoke-static {v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->k(Lcom/ninesky/browser/provider/downloads/DownloadService;)Lcom/ninesky/browser/provider/downloads/a;

    move-result-object v2

    iget-object v4, v2, Lcom/ninesky/browser/provider/downloads/a;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    monitor-enter v4

    :try_start_2
    iget-object v5, v2, Lcom/ninesky/browser/provider/downloads/a;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    invoke-static {v5}, Lcom/ninesky/browser/provider/downloads/DownloadService;->b(Lcom/ninesky/browser/provider/downloads/DownloadService;)Landroid/media/IMediaScannerService;

    move-result-object v5

    if-eqz v5, :cond_18

    iget-object v5, v2, Lcom/ninesky/browser/provider/downloads/a;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    const/4 v6, 0x0

    invoke-static {v5, v6}, Lcom/ninesky/browser/provider/downloads/DownloadService;->a(Lcom/ninesky/browser/provider/downloads/DownloadService;Landroid/media/IMediaScannerService;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1

    :try_start_3
    iget-object v5, v2, Lcom/ninesky/browser/provider/downloads/a;->a:Lcom/ninesky/browser/provider/downloads/DownloadService;

    invoke-virtual {v5, v2}, Lcom/ninesky/browser/provider/downloads/DownloadService;->unbindService(Landroid/content/ServiceConnection;)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1
    .catch Ljava/lang/IllegalArgumentException; {:try_start_3 .. :try_end_3} :catch_0

    :cond_18
    :goto_a
    :try_start_4
    monitor-exit v4

    goto/16 :goto_3

    :catchall_1
    move-exception v2

    monitor-exit v4
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    throw v2

    :catch_0
    move-exception v2

    goto :goto_a

    :cond_19
    move v7, v4

    move-wide v4, v12

    goto :goto_9

    :cond_1a
    move v2, v5

    move v4, v7

    goto :goto_8

    :cond_1b
    move v7, v4

    move-wide v4, v12

    goto/16 :goto_7

    :cond_1c
    move v2, v5

    move v4, v7

    goto/16 :goto_6

    :cond_1d
    move v7, v4

    move-wide v4, v12

    goto/16 :goto_5

    :cond_1e
    move v2, v5

    move v4, v7

    goto/16 :goto_4
.end method
